
var defId = T.p("defId");
$(function () {
    $("#jqGrid").jqGrid({
        url: '../monitorDefineLn/list',
        datatype: "json",
        postData:{
            defId:defId
        },
        colModel: [
			{ label: 'id', name: 'id', width: 50, key: true },
			{ label: '监控定义id', name: 'defId',index:'def_id', width: 80 },
			{ label: '描述', name: 'description',index:'description', width: 80 },
			{ label: 'sql', name: 'sqlText',index:'sql_text', width: 80 },
			{ label: 'dbKey', name: 'dbKey',index:'db_key', width: 80 },
			{ label: '邮件模板', name: 'emailTmpl',index:'email_tmpl', width: 80 },
			{ label: '短信发送阈值属性', name: 'smsLimitProp',index:'sms_limit_prop', width: 80 },
			{ label: '短信发送阈值', name: 'smsLimitValue',index:'sms_limit_value', width: 80 },
			{ label: '短信发送模板', name: 'smsTmpl',index:'sms_tmpl', width: 80 }
        ],
		viewrecords: true,
        height: 800,
        rowNum: 20,
		rowList : [20,30,50],
        rownumbers: true, 
        rownumWidth: 25, 
        autowidth:true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader : {
			root: "page.data",
			page: "page.pageNo",
			total: "page.pageCount",
			records: "page.count"
        },
        prmNames : {
            page:"page", 
            rows:"limit", 
            order: "order"
        },
        gridComplete:function(){
        	//隐藏grid底部滚动条
        	//$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
        }
    });
});

var vm = new Vue({
	el:'#rrapp',
	data:{
		isShowCond:false,
        btnText:'查询',
        qryForm:{
        }
	},
	methods: {
        create:function (event) {
            location.href = "monitorDefineLn_add.html?defId="+defId;
        },
		reset: function(){

        },
        query: function () {
            $("#jqGrid").jqGrid('setGridParam',{
                postData:{
                },
                page:1
            }).trigger("reloadGrid");
        },
        toggle:function(){
            this.isShowCond = !this.isShowCond;

            if(this.isShowCond==true){
                this.btnText = "隐藏"
            }else if(this.isShowCond==false){
                this.btnText = "查询"
            }

        },
        back: function (event) {
            history.go(-1);
        },
		update: function (event) {
			var id = getSelectedRow();
			if(id == null){
				return ;
			}
			
			location.href = "monitorDefineLn_add.html?id="+id;
		},
		del: function (event) {
			var ids = getSelectedRows();
			if(ids == null){
				return ;
			}
			
			confirm('确定要删除选中的记录？', function(){
				$.ajax({
					type: "POST",
				    url: "../monitorDefineLn/delete",
				    data: JSON.stringify(ids),
				    success: function(r){
						if(r.code == 0){
							alert('操作成功', function(index){
								$("#jqGrid").trigger("reloadGrid");
							});
						}else{
							alert(r.msg);
						}
					}
				});
			});
		}
	}
});
